package com.ckzp.weixin.service.response;

import com.alibaba.fastjson.JSON;
import com.ckzp.core.util.XmlUtil;
import com.ckzp.weixin.service.ServiceRequest;
import com.ckzp.weixin.service.ServiceResponse;

import java.util.Date;

/**
 * Created by 51594 on 2023/4/7.
 */
public class TextResponse implements ServiceResponse{
    /**
     *
     */
    public String ToUserName;
    /**
     *
     */
    public String FromUserName;
    /**
     *
     */
    public Long CreateTime = new Date().getTime();
    /**
     *
     */
    public String MsgType;
    /**
     *
     */
    public String Content;
    /**
     *
     */
    public Integer FuncFlag = 0;

    public String getToUserName() {
        return ToUserName;
    }

    public void setToUserName(String toUserName) {
        ToUserName = toUserName;
    }

    public String getFromUserName() {
        return FromUserName;
    }

    public void setFromUserName(String fromUserName) {
        FromUserName = fromUserName;
    }


    public Long getCreateTime() {
        return CreateTime;
    }

    public void setCreateTime(Long createTime) {
        CreateTime = createTime;
    }

    public String getMsgType() {
        return MsgType;
    }

    public void setMsgType(String msgType) {
        MsgType = msgType;
    }

    public String getContent() {
        return Content;
    }

    public void setContent(String content) {
        Content = content;
    }

    public Integer getFuncFlag() {
        return FuncFlag;
    }

    public void setFuncFlag(Integer funcFlag) {
        FuncFlag = funcFlag;
    }

    /**
     * \
     *
     * @return
     */
    public String toJson() {
        return JSON.toJSONString(this);
    }

    /**
     * @return
     */
    public String toXml() {
        return XmlUtil.toXml(this, "xml");
    }

    public static TextResponse n() {
        return new TextResponse();
    }

    /**
     * @param req
     * @return
     */
    public static TextResponse init(ServiceRequest req) {
        TextResponse res = TextResponse.n();
        res.setFromUserName(req.getToUserName());
        res.setToUserName(req.getFromUserName());
        res.setMsgType("text");
        res.setContent(req.getContent());
        //res.setCreateTime(req.getCreateTime());
        return res;
    }
}
